/**
* 左边菜单
*/ 
<template>
  <div>
    <el-menu
      default-active="2"
      :collapse="collapsed"
      collapse-transition
      router
      v-bind="$route.path"
      unique-opened
      class="el-menu-vertical-demo"
      background-color="#334157"
      text-color="#fff"
      active-text-color="#ffd04b"
    >
      <div class="logobox">
        <img class="logoimg" src="../assets/img/logo.png" alt="" />
        <h3>华清物联web系统</h3>
      </div>
      <!-- <v-if ></v-if> -->
      <el-submenu
        v-for="menu in allmenu"
        :key="menu.menuid"
        :index="menu.menuname"
      >
        <template slot="title">
          <i class="iconfont" :class="menu.icon"></i>
          <span>{{ menu.menuname }}</span>
        </template>
        <el-menu-item-group>
          <el-menu-item
            v-for="chmenu in menu.menus"
            :index="'/' + chmenu.url"
            :key="chmenu.menuid"
          >
            <i class="iconfont" :class="chmenu.icon"></i>
            <span>{{ chmenu.menuname }}</span>
          </el-menu-item>
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
  </div>
</template>
<script>
export default {
  name: "leftnav",
  data() {
    return {
      code: this.$route.query.code,
      collapsed: false,
      allmenu: [],
      res : {
      success: true,
      data: [
        {
          menuid: 1,
          icon: "li-icon-xiangmuguanli",
          menuname: "状态",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 2,
              icon: "icon-cat-skuQuery",
              menuname: "系统信息",
              hasThird: "N",
              url: "goods/Goods",
              menus: null,
            },
          ],
        },
        {
          menuid: 33,
          icon: "li-icon-xitongguanli",
          menuname: "上报服务",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 34,
              icon: "icon-order-manage",
              menuname: "交易订单",
              hasThird: "N",
              url: "pay/Order",
              menus: null,
            },
          ],
        },
        {
          menuid: 71,
          icon: "li-icon-shangchengxitongtubiaozitihuayuanwenjian91",
          menuname: "系统维护",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 72,
              icon: "icon-cus-manage",
              menuname: "用户管理",
              hasThird: "N",
              url: "system/User",
              menus: null,
            },
            {
              menuid: 129,
              icon: "icon-provider-manage",
              menuname: "菜单管理",
              hasThird: "N",
              url: "system/Module",
              menus: null,
            },
            {
              menuid: 73,
              icon: 'icon-news-manage',
              menuname: '角色管理',
              hasThird: 'N',
              url: 'system/Role',
              menus: null
            },
            {
              menuid: 74,
              icon: 'icon-cs-manage',
              menuname: '公司管理',
              hasThird: 'N',
              url: 'system/Dept',
              menus: null
            },
            {
              menuid: 75,
              icon: 'icon-promotion-manage',
              menuname: '系统环境变量',
              hasThird: 'N',url: 'system/Variable',
              menus: null
            },
            {
              menuid: 76,
              icon: 'icon-cms-manage',
              menuname: '权限管理',
              hasThird: 'N',
              url: 'system/Permission',
              menus: null
            }
          ]
        },
        {
          menuid: 128,
          icon: "li-icon-shangchengxitongtubiaozitihuayuanwenjian91",
          menuname: "参数设置",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 159,
              icon: "icon-provider-manage",
              menuname: "通讯接口",
              hasThird: "N",
              url: "service/MachineConfig",
              menus: null,
            },
            {
              menuid: 76,
              icon: "icon-cms-manage",
              menuname: "从机设备",
              hasThird: "N",
              url: "service/Config",
              menus: null,
            },
          ],
        },
        
      ],
      msg: "success",
    }
    };
  },
  // 创建完毕状态(里面是操作)
  created() {
    // 监听
    this.allmenu = this.res.data;
    this.$router.push('/goods/Goods')
    // this.$root.Bus.$on("toggle", (value) => {
    //   this.collapsed = !value;
    // });
  },
  mounted() {
    // console.log(this.code);
    // // 普通用户
    // if (this.code == 201) {
    //   this.allmenu = this.res.data2;
    //   // 管理员
    // } else if (this.code == 202) {
    //   this.allmenu = this.res.data1;
    // } else if (this.code == 200) {
    //   alert("账号未审核");
    //   this.$router.push('/login')
    // } 
  },
};
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 240px;
  min-height: 747px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;
}
.el-menu-item-group__title {
  padding: 0px;
}
.el-menu-bg {
  background-color: #1f2d3d !important;
}
.el-menu {
  border: none;
}
.logobox {
  height: 40px;
  line-height: 40px;
  color: #9d9d9d;
  font-size: 20px;
  text-align: center;
  padding: 20px 0px;
  position: relative;
}
.logoimg {
  height: 40px;
  margin-left: -200px;
}
.logobox h3 {
  position: absolute;
  top: -4px;
  left: 50px;
  color: white;
}
</style>